home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6274 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: news.ov.com!news
  2. From: glenn@ov.com (Fletcher.Glenn@ov.com)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Help Me !
  5. Date: 23 Feb 1996 17:01:13 GMT
  6. Organization: OpenVision
  7. Message-ID: <4gkrsp$g18@spanky.pls.ov.com>
  8. References: <4geh23$e3u@newsbf02.news.aol.com>
  9. Reply-To: glenn@ov.com
  10. NNTP-Posting-Host: foghorn.pls.ov.com
  11.  
  12. In article e3u@newsbf02.news.aol.com, mackboring@aol.com (MackBoring) writes:
  13. >I need to create a program to display a list of the first 1000 prime
  14. >integers (starting with 2) you need test only odd numbers and for
  15. >divisibilty with odd numbers
  16.  
  17.  
  18. Let's do a little thinking here.  A prime number is not evenly divisable
  19. by any numbers except itself and one.  Further, the only numbers necessary
  20. to test a prime number is other primes.  Lastly, if you have tested with
  21. primes < test_number/2, then you need not test with greater primes as
  22. 2 is the smallest prime result possible.  In fact, as you test with the
  23. samllest primes first, the largest necessary prime to test with is reduced
  24. accordingly.  i.e. if you test with three and fail, then the largest prime
  25. to test with is < your test_number/3, and so forth.  If you have tested with
  26. 2 and 3 (primes) do you see why you don't have to test with 6 (non-prime)?
  27.  
  28.             Fletcher.Glenn@ov.com
  29.  
  30.  
  31.